package com.tinymooc.common.domain;

/**
 * Created by 哓哓 on 2015/11/26 0026.
 */
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * UserCourse generated by hbm2java
 */
@Entity
@Table(name = "user_course", catalog = "tinymooc")
public class UserCourse implements java.io.Serializable {

    private String userCourseId;
    private User user;
    private Course course;
    private String userPosition;
    private String learnState;
    private Date startDate;
    private Set<Note> notes = new HashSet<Note>(0);

    public UserCourse() {
    }

    public UserCourse(String userCourseId) {
        this.userCourseId = userCourseId;
    }

    public UserCourse(String userCourseId, User user, Course course,
                      String userPosition, String learnState, Date startDate,
                      Set<Note> notes) {
        this.userCourseId = userCourseId;
        this.user = user;
        this.course = course;
        this.userPosition = userPosition;
        this.learnState = learnState;
        this.startDate = startDate;
        this.notes = notes;
    }

    @Id
    @Column(name = "USER_COURSE_ID", unique = true, nullable = false, length = 32)
    public String getUserCourseId() {
        return this.userCourseId;
    }

    public void setUserCourseId(String userCourseId) {
        this.userCourseId = userCourseId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "USER_ID")
    public User getUser() {
        return this.user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "COURSE_ID")
    public Course getCourse() {
        return this.course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    @Column(name = "USER_POSITION", length = 50)
    public String getUserPosition() {
        return this.userPosition;
    }

    public void setUserPosition(String userPosition) {
        this.userPosition = userPosition;
    }

    @Column(name = "LEARN_STATE", length = 50)
    public String getLearnState() {
        return this.learnState;
    }

    public void setLearnState(String learnState) {
        this.learnState = learnState;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "START_DATE", length = 19)
    public Date getStartDate() {
        return this.startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "userCourse")
    public Set<Note> getNotes() {
        return this.notes;
    }

    public void setNotes(Set<Note> notes) {
        this.notes = notes;
    }
}
